package com.demo.sender.totp.twilio;

import com.twilio.Twilio;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author wangfengchen
 */
@Slf4j
@Data
@Component
public class TwilioConfig {

  @Value("${totp.twilio.accountSid:not_set}")
  private String accountSid;
  @Value("${totp.twilio.authToken:not_set}")
  private String authToken;
  @Value("${totp.twilio.serviceId:not_set}")
  private String serviceId;


  @PostConstruct
  private void init() {
    Twilio.init(accountSid, authToken);
    log.info("Twilio client初始化成功");
  }

  @PreDestroy
  private void destroy() {
    Twilio.destroy();
    log.info("Twilio client关闭成功");
  }


}
